<?php
namespace app\middleware;

use think\facade\Session;

class AuthMemberMiddleware{

    public function handle($request, \Closure $next){
        // 搞事情
        $cookies = $request->cookie() ;
        //dump($cookies);
        if( !empty( $request->get('sid','') ) ){
            //$cookies['PHPSESSID'] = $request->get('sid') ;
            Session::setId($request->get('sid'));
            Session::init();
        }

        if( !Session::has('member_info') ){
            return redirect(url('members/Index/login'),401);
        }

        return $next($request);
    }
}
